package gui;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.border.LineBorder;

/**
 *
 * @author SUCCESS\quannguyen
 */
public class Thumbnail extends JLabel {

    public Thumbnail(ImageIcon icon, LineBorder border) {
        super(icon);
        this.setBorder(border);
        this.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                int index = e.getComponent().getParent()
                        .getComponentZOrder(e.getComponent());
                ImageListShower imageListShower =
                        (ImageListShower) e.getComponent().getParent()
                        .getParent().getParent().getParent();
                imageListShower.setCurrentImage(index);
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }
        });
    }
}
